<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>资管客户还款管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
    <form id="insCstRepay_form">
        <div class="fieldset1 tabel_col tabel_col_1 clearFix">
            <div class="fieldBox col_100">
                <div class="label">资方支付表号</div>
                <div class="field">
                    ${insCstRepaySettleVO.paySchNo}
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label">还款期次</div>
                <div class="field">
                    <input name="payPd" id="payPd" type="text" class="ui-textbox"
                           value="" validate="{required:true}">
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
            <div class="fieldBox col_50">
                <div class="label">还款金额</div>
                <div class="field">
                    <input name="repayTtlAmt" id="repayTtlAmt" type="text" class="ui-textbox"
                           value="" validate="{required:true}">
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
           <%-- <div class="fieldBox col_100" id="errorMsgDiv" style="display:none;">
                <div class="label">错误描述</div>
                <div class="field">
                    <span class="requiredSymbol" id="errorMsg">${errorMsg}</span>
                </div>
            </div>--%>


        </div>
    </form>
<script>
    var grid = null,form=null;
    $(function() {
         form = $("#insCstRepay_form").ligerForm({
            validate: true
        });
        var dialog = frameElement.dialog; //调用页面的dialog对象(ligerui对象)
        //按钮在页面外的Dialog里，给Dialog绑定事件 （onOk 和 onCancel）
        frameElement.dialog.onOk = function () {
            if (!form.valid()) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
                return false; //验证不通过，不执行以下代码
            }
            frameElement.dialog.disabledBtns();
            frameElement.dialog.mask();

            var payPd = $("#payPd").val();
            var repayTtlAmt = $("#repayTtlAmt").val();
            var _url= '<%=path%>/repay/insCstRepaySettle/repayOrsettle.do';
            var data = {"id":"${insCstRepaySettleVO.id}","prjId":"${insCstRepaySettleVO.prjId}","insId":"${insCstRepaySettleVO.insId}","type":"repay","payPd":payPd,"repayTtlAmt":repayTtlAmt,"insCode":"${insCstRepaySettleVO.insCode}"};
            var wait_dialog;

            $.ligerDialog.confirm("是否确定提前还款？", function (flag) {
                if (flag == false) return;
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: data,
                    url: _url,
                    beforeSend: function () {
                        wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                    },
                    success: function (msg) {
                        wait_dialog.close();
                        if (msg.success == 1) {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                            frameElement.dialog.close();
                        } else {
                            $.ligerDialog.SQalert({content: msg.info, SQ_type: "error", SQ_showButtons: true});
                        }
                    }
                });
            });
        }

        frameElement.dialog.onCancel = function () {
            frameElement.dialog.hide();
        };

    });
</script>
</body>
</html>
